//
//  DashLineView.m
//  UEAssistant
//
//  Created by mac on 2017/8/1.
//  Copyright © 2017年 youyixinxi. All rights reserved.
//

#import "DashLineView.h"

@interface DashLineView (){

    NSInteger       _lineLength;
    NSInteger       _lineSpacing;
    UIColor         *_lineColor;
    CGFloat         _height;
}

@end

@implementation DashLineView

- (instancetype)initWithFrame:(CGRect)frame withLineLength:(NSInteger)lineLength withLineSpacing:(NSInteger)lineSpacing withLineColor:(UIColor *)lineColor{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        _lineLength = lineLength;
        _lineSpacing = lineSpacing;
        _lineColor = lineColor;
        _height = frame.size.height;
    }
    return self;
}

- (void)drawRect:(CGRect)rect {

    CGContextRef context =UIGraphicsGetCurrentContext();
    CGContextBeginPath(context);
    CGContextSetLineWidth(context,1);
    CGContextSetStrokeColorWithColor(context, _lineColor.CGColor);
    CGFloat lengths[] = {_lineLength,_lineSpacing};
    CGContextSetLineDash(context, 0, lengths,2);
    CGContextMoveToPoint(context, 0, 0);
    CGContextAddLineToPoint(context, 0,_height);
    CGContextStrokePath(context);
//  CGContextClosePath(context);

}

@end
